<?php
	
require_once("header.php");

	//select all the user that the current logged in use is allow to view record for.
	//Administrator can view all users
	//Supervisor can view all users in their department
	$result = mysql_query("SELECT * FROM user WHERE id = '".$_SESSION['id']."'") or die(mysql_error());
	
	$data = mysql_fetch_assoc($result);
	
	if ($data['role'] == "Administrator") {
		$result = mysql_query("SELECT * FROM user where role = 'User'") or die(mysql_error());
	}
	else if ($data['role'] == "Supervisor") {
		$result = mysql_query ("SELECT * FROM user where role = 'User' AND department = '".$data['department']."' ORDER BY name ASC") or die (mysql_error());
	}
	
?>
<script>
	$(function() {
		$("#date").datepicker({
			
			showOn: "both",
			buttonImage: "../css/redmond/images/calendar.gif",
			changeMonth: true,
			buttonImageOnly: true,
			dateFormat: 'yy-mm'
		});
	});

</script>

<div id="body" class="clear">
			<div class="clear">
				<div class="column">
					 <fieldset>
        
                        <legend>Export to Excel</legend>
                        	<form id="viewStaffForm"  method="post" action="taController.php?request=export-records&return=<?php echo $domain; ?>/download.php" enctype="multipart/form-data">
                       	    	<p><label for="staff">Staff:</label>
                            	<select name="staff" style="width: 186px">
                            		<?php if($_SESSION['role'] == "User") { ?>
                            		<option value=<?php echo $_SESSION['id']?>><?php echo $_SESSION['name']?> </option>
                            		<?php } //end iff
                            		      else {
                            				while($data = mysql_fetch_assoc($result)) { ?>
                            					<option value=<?php echo $data['id']?>><?php echo $data['name']?> </option>
                            		<?php 	}
                            			  }//end else
                            		?>	
                            	</select></p>
                            	
                            	<p><label for="date">Date:</label>
                            	<input name="date" id="date" type="text" style="width: 173px"/></p>
                            	
                            	<p><input name="send" class="formbutton" value="Download" type="submit" style="float:left"/></p>
                            	</form>
                      </fieldset>
                  </div>
                 </div>
                 </div>

<?php 
	require_once("footer.php");
	
?>